@extends('admin.base.index')

@section('content')
    <!-- Deafult Table -->
    <div class="block-area" id="defaultStyle">
        <h3 class="block-title">商品管理</h3>
        <form action='/config' method='post' name='myform'>
            <input type='hidden' name='_token' value='{{ csrf_token() }}'>
            <input type='hidden' name='_method' value='DELETE'>
        </form>
        <form action='/admin/config' method='get'>
            <div class='media-body'>
                商品名：<input type='text' class='form-control m-b-5' name='name'>
            </div>
            <input type='submit' class='btn' value='搜索'>
        </form>
        <table class="table tile">
            <thead>
                <tr>
                    <th>NO.</th>
                    <th>商品名称</th>
                    <th>所属分类</th>
                    <th>价格</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <span style="display:none;">{{$num=1}}</span>
                @foreach($list as $v)
                <tr>
                    <td>{{ $num }}</td>
                    <td>{{ $v->goodname }}</td>
                    <td>{{ $v->name }}</td>
                    <td>{{ $v->price }}</td>
                    <td>
                        <a href="javascript:doDel({{ $v->id }})" class='btn'>下架</a>
                    </td>
                </tr>
                <span style="display:none;">{{$num++}}</span>
                @endforeach
            </tbody>
        </table>
        {{ $list->appends($where)->links() }}
        <script type="text/javascript">
            function doDel(id)
            {
                if(confirm('确定要删除吗？')){
                    var form = document.myform;
                    form.action = 'goods/'+id;
                    form.submit()
                }
            }
        </script>
    </div>
@stop
